﻿/*   */
$(function () {
    echarts_ajxx();//案件柱状图
    echarts_jaqk();//积案情况-下钻
    echarts_cqyj();//超期预警饼图-下钻-已动态获取数据
    echarts_cbrk();//查补入库折线图-已动态获取
    echarts_jcsr();//全市稽查收入-已动态获取数据
    echarts_nknsh();//内控内生化


    function echarts_ajxx() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_ajxx'));
        //dataScope=数据权限：jcyj(稽查一局)、sysj(沈阳市局)
        var dataScope = "sysj";
        CoreUtil.sendPost("/statistics/indexAjxxZzt", {"dataScope":dataScope}, function (res) {
            var qj = res.data.qj;
            var k1 = res.data.k1;
            var k2 = res.data.k2;
            var k3 = res.data.k3;
            var k4 = res.data.k4;
            var k5 = res.data.k5;
            var jcyj_option = {
                title: {
                    text: '案件情况',
                    bottom: '10',
                    left: 'center'
                },
                legend: {},
                tooltip: {},
                dataset: {
                    source: [
                        ['product', '立案', '检查', '审理', '审结', '结案'],
                        qj,k1,k2,k3,k4,k5
                        // ['全局', 43.3, 85.8, 93.7, 12, 14],
                        // ['一科', 83.1, 73.4, 55.1, 12, 14],
                        // ['二科', 86.4, 65.2, 82.5, 12, 14],
                        // ['三科', 72.4, 53.9, 39.1, 12, 14],
                        // ['四科', 86.4, 65.2, 82.5, 12, 14],
                        // ['五科', 86.4, 65.2, 82.5, 12, 14]
                    ]
                },
                xAxis: {type: 'category'},
                yAxis: {},
                // Declare several bar series, each will be mapped
                // to a column of dataset.source by default.
                series: [{type: 'bar'}, {type: 'bar'}, {type: 'bar'}, {type: 'bar'}, {type: 'bar'}]
            };
            var sysj_option = {
                title: {
                    text: '案件情况',
                    bottom: '10',
                    left: 'center'
                },
                legend: {},
                tooltip: {},
                dataset: {
                    source: [
                        ['product', '立案', '检查', '审理', '审结', '结案'],
                        qj,k1,k2,k3,k4
                        // ['全局', 43.3, 85.8, 93.7, 12, 14],
                        // ['一科', 83.1, 73.4, 55.1, 12, 14],
                        // ['二科', 86.4, 65.2, 82.5, 12, 14],
                        // ['三科', 72.4, 53.9, 39.1, 12, 14],
                        // ['四科', 86.4, 65.2, 82.5, 12, 14],
                        // ['五科', 86.4, 65.2, 82.5, 12, 14]
                    ]
                },
                xAxis: {type: 'category'},
                yAxis: {},
                series: [{type: 'bar'}, {type: 'bar'}, {type: 'bar'}, {type: 'bar'}, {type: 'bar'}]
            }
            if(dataScope == "jcyj"){
                myChart.setOption(jcyj_option);
            }else if (dataScope == "sysj"){
                myChart.setOption(sysj_option);
            }
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    function echarts_jaqk() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_jaqk'));
        CoreUtil.sendPost("/statistics/indexJiAn", null, function (res) {
            var zc = res.data.zc;
            var zs = res.data.zs;
            var zzx = res.data.zzx;
            var bj = res.data.bj;
            var ja = res.data.ja;
            myChart.setOption({
                title: {
                    text: '积案情况',
                    bottom: '0',
                    left: 'center'
                },
                tooltip: {},
                angleAxis: {},
                radiusAxis: {
                    type: 'category',
                    data: ['一科', '二科', '三科', '四科', '五科'],
                    z: 10
                },
                polar: {},
                series: [
                    {
                        type: 'bar',
                        data: zc,
                            // [1, 2, 3, 4, 5],
                        coordinateSystem: 'polar',
                        name: '检查',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    },
                    {
                        type: 'bar',
                        data: zs,
                            // [2, 4, 6, 8, 10],
                        coordinateSystem: 'polar',
                        name: '审理',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    },
                    {
                        type: 'bar',
                        data: zzx,
                            // [1, 2, 3, 4, 5],
                        coordinateSystem: 'polar',
                        name: '执行',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    }
                    ,
                    {
                        type: 'bar',
                        data: bj,
                            // [1, 2, 3, 4, 5],
                        coordinateSystem: 'polar',
                        name: '办结',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    }
                    ,
                    {
                        type: 'bar',
                        data: ja,
                            // [1, 2, 3, 4, 5],
                        coordinateSystem: 'polar',
                        name: '结案',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    }
                ],
                legend: {
                    show: true,
                    data: ['检查', '审理', '执行', '办结', '结案']
                }
            });
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
        myChart.on('click', function(params) {
           var swjgmc =  params.name;//五科
           var ajztDm = params.seriesName;//检查
            //跳转到调查核实功能
            skipOpen("/index/attention/jaqk?swjgmc="+swjgmc+"&ajztDm="+ajztDm,"80303","积案情况");
        });
    }


    function echarts_nknsh() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_nknsh'));
        CoreUtil.sendPost("/statistics/indexNknsh", null, function (res) {
            var tx = res.data.tx;
            var db = res.data.db;
            myChart.setOption({
                title: {
                    text: '内控内生化',
                    bottom: '0',
                    left: 'center'
                },
                tooltip: {},
                angleAxis: {},
                radiusAxis: {
                    type: 'category',
                    data: ['一科', '二科', '三科', '四科', '五科'],
                    z: 10
                },
                polar: {},
                series: [
                    {
                        type: 'bar',
                        data: tx,
                        coordinateSystem: 'polar',
                        name: '提醒',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    },
                    {
                        type: 'bar',
                        data: db,
                        coordinateSystem: 'polar',
                        name: '督办',
                        stack: 'a',
                        emphasis: {
                            focus: 'series'
                        }
                    }
                ],
                legend: {
                    show: true,
                    data: ['提醒', '督办']
                }
            });
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    function echarts_cqyj() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_cqyj'));
        //dataScope=数据权限：jcyj(稽查一局)、sysj(沈阳市局)
        var reqParams = {
            "username":"0CF9F5103FA0429B8C0224AF56A1D63B",
            "password":"0CF9F5103FA0429B8C0224AF56A1D63B",
            "serviceId":"0001",
            "param": {
                "dataScope":'sysj'
            }
        };
        CoreUtil.sendPost("/thirdparty/dataVisualization/getInspectionData", reqParams, function (res) {
            var dataList = res.result.list;
            var actData = [];
            for (var i=0;i<dataList.length;i++) {
                var objdata={};
                var resDataObj = dataList[i];
                var value = resDataObj.hs;
                var name = resDataObj.xm;
                var dayType  = getDayTypeByName(name);
                objdata.value=value;
                objdata.name = name;
                objdata.dayType =dayType;
                actData.push(objdata);
            }
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption({
                title: {
                    text: '超期预警',
                    bottom:'10',
                    left:'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter:'{b}<br />{a}:{c}件'
                },
                legend: {
                    orient: 'horizontal',
                    left: 'center'
                },
                series: [
                    {
                        name: '案件数量',
                        type: 'pie',
                        minAngle:20,
                        radius: '50%',
                        data:actData
                        //     [
                        //     { value: 1048, name: '30天',dayType:'1' },
                        //     { value: 735, name: '40天',dayType:'2' },
                        //     { value: 580, name: '50天',dayType:'3' },
                        //     { value: 484, name: '60天',dayType:'4' },
                        //     { value: 300, name: '70天',dayType:'5' },
                        //     { value: 300, name: '80天',dayType:'6' },
                        //     { value: 300, name: '90天以上',dayType:'7' }
                        // ]
                        ,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            });
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
        myChart.on('click', function(params) {
            //跳转到案件预警功能
            skipOpen("/index/attention/cqyj?dayType="+params.data.dayType,"80301","案件预警");
        });
    }
    function getDayTypeByName(name){
        var dayType="";
        if(name.indexOf('30')!= -1){
            dayType = '1';
        }
        if(name.indexOf('40')!= -1){
            dayType = '2';
        }
        if(name.indexOf('50')!= -1){
            dayType = '3';
        }
        if(name.indexOf('60')!= -1){
            dayType = '4';
        }
        if(name.indexOf('70')!= -1){
            dayType = '5';
        }
        if(name.indexOf('80')!= -1){
            dayType = '6';
        }
        if(name.indexOf('90')!= -1){
            dayType = '7';
        }
        return dayType;
    }
    function echarts_cbrk() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_cbrk'));
        //dataScope=数据权限：jcyj(稽查一局)、sysj(沈阳市局)
        CoreUtil.sendPost("/statistics/indexCbAndRk", {"dataScope":"sysj"}, function (res) {
            var cbData = res.data.cbData;
            var rkData = res.data.rkData;
            myChart.setOption({
                title: {
                    text: '查补入库（万元）',
                    bottom: '10',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {},
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                    axisLabel: {
                        interval:0
                        // rotate:30,
                        //  margin:2
                        // padding:4
                    }
                },
                yAxis: {
                    type: 'value',
                    axisLabel: {
                        formatter: '{value} '
                    }
                },
                series: [
                    {
                        name: '查补',
                        type: 'line',
                        data: cbData
                            // [10, 11, 13, 11, 12, 12, 9, 12, 9, 12, 9, 12]
                    },
                    {
                        name: '入库',
                        type: 'line',
                        data: rkData
                            // [9, 15, 16, 7, 9, 15, 18, 15, 16, 7, 9, 15]
                    }
                ]
            });
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    function echarts_jcsr() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('echarts_jcsr'));
        //dataScope=数据权限：jcyj(稽查一局)、sysj(沈阳市局)
        CoreUtil.sendPost("/statistics/indexQsjcsr", {"dataScope":"sysj"}, function (res) {
            var categoryData = res.data.categoryData;
            var seriesData = res.data.seriesData;
            let date = new Date(); //获取当前时间
            let year = date.getFullYear(); //获取当前年份
            myChart.setOption({
                title: {
                    text: '全市稽查收入（万元）'
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'shadow'
                    }
                },
                legend: {
                    right: '20'
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                xAxis: {
                    type: 'value',
                    boundaryGap: [0, 0.01]
                },
                yAxis: {
                    type: 'category',
                    data:
                    categoryData
                    //     [
                    //     '沈北',
                    //     '辉山',
                    //     '高新',
                    //     '浑南',
                    //     '大东',
                    //     '沈河',
                    //     '和平',
                    //     '新民',
                    //     '辽中',
                    //     '于洪',
                    //     '皇姑',
                    //     '经开',
                    //     '铁西',
                    //     '全市'
                    // ]
                },
                series: [
                    {
                        name: year,
                        type: 'bar',
                        barMinHeight:2,
                        data:
                        seriesData
                        //     [
                        //     18203, 23489, 29034, 14970, 11744, 34343, 23489, 29034, 14970,
                        //     11744, 14444, 23489, 29034, 44970
                        // ]
                    }
                ]
            });
        });
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }
})

















